# Maintainer: Noel Kuntze <noel.kuntze@contauro.com>
pkgname=grommunio-admin-web
pkgver=2.9.0
pkgrel=3
pkgdesc="Frontend for grommunio management"
# s390x: blocked by grommunio-gromox through grommunio-admin-api
# loongarch64: blocked by grommunio-admin-api
arch="noarch !riscv64 !s390x !loongarch64"
url="https://grommunio.com/"
license="AGPL-3.0-only"
options="!check" # No test suite
depends="grommunio-admin-api grommunio-admin-common"
makedepends="npm"

source="$pkgname-$pkgver.tar.gz::https://github.com/grommunio/admin-web/archive/refs/tags/$pkgver.tar.gz
	config.json
	"

builddir="$srcdir/admin-web-$pkgver"

build() {
	echo $pkgver-$pkgrel > .version
	make YARN=npm
}

package() {
	# webapp
	install -dm0755 "$pkgdir/usr/share/webapps/"
	cp -rp build "$pkgdir/usr/share/webapps/$pkgname"

	# license
	install -Dm644 LICENSE.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

	# nginx conf
	sed -i "s@/usr/share/grommunio-admin-web@/usr/share/webapps/grommunio-admin-web@" conf/web.conf
	install -Dpm644 conf/web.conf "$pkgdir/usr/share/grommunio-admin-common/nginx.d/web.conf"

	# config.json
	install -Dm644 "$srcdir/config.json" "$pkgdir/etc/grommunio-admin-common/config.json"
}

sha512sums="
c0dccb101de6acb6b54e1f839b62417a9d7cd45687d715e193e318b3d73dfd978afd80729cd2bfb1a2b7409985da721fa9aa5a7f22f65dbf920dd205a0d2bf64  grommunio-admin-web-2.9.0.tar.gz
41e6df23c37b786a214e3c41e1e53ee18a3bd2e6d6344245dc0879374685b0e986f5bc3daeb9068907856810457e3deca6840837d1938af55238335b2b6e99e3  config.json
"
